package cn.edu.hpu.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.hpu.dao.GoalDao;
import cn.edu.hpu.entity.Employee;
import cn.edu.hpu.entity.Goal;
import cn.edu.hpu.entity.Project;
import cn.edu.hpu.utitl.TimeUtitl;

public class UpdateGoalServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=GBK");
		String gid = request.getParameter("gid");
		String gname = request.getParameter("gname");
		String gdsp = request.getParameter("gdsp");
		String gctime = TimeUtitl.getTime();
		HttpSession session = request.getSession();
		Employee e = (Employee)session.getAttribute("employee");
		String eid = e.getEid();
		Project p = (Project)session.getAttribute("project");
		String pid =p.getPid();
		Goal g = new Goal();
		g.setEid(eid);
		g.setGctime(gctime);
		g.setGdsp(gdsp);
		g.setGid(gid);
		g.setGname(gname);
		g.setPid(pid);

		GoalDao gd = new GoalDao();
		gd.updateAGoal(g);
		
		List<Goal> list = gd.findAllGoal();
		request.setAttribute("glist", list);
		request.getRequestDispatcher("/WEB-INF/views/goal.jsp").forward(request, response);
		
	}

}
